package condition;

import be.kuleuven.cs.som.annotate.Basic;
import exceptions.IllegalConditionException;

/**
 * A class of binary composed conditions.
 *   A binary composed condition involves a single operator applied
 *   to two conditions.
 * 
 * @version	3.0
 * @author 	Lies Tambeur 	r0264469	2Bcwsbbh
 * @author	Eline Vanrykel	r0264543	2Bcwselt
 *
 */
public abstract class BinaryComposedCondition extends ComposedCondition {
	protected Condition conditionOne;
	protected Condition conditionTwo;
	
	/**
	 * Initialize this new binary composed condition with given conditions.
	 *
	 * @param 	conditionOne
	 * 			The first condition for this binary composed condition.
	 * @param 	conditionTwo
	 * 			The second condition for this binary composed condition.
	 * @post   	The first condition of this new binary composed condition is the
	 *         	same as the given conditionOne.
	 * @post   	The second condition of this new binary composed condition is the
	 *         	same as the given conditionTwo.
	 * @throws 	IllegalConditionException
	 * 			This new binary composed condition cannot have one
	 * 			of the two given conditions.      
	 */
	protected BinaryComposedCondition(Condition conditionOne, Condition conditionTwo) throws IllegalConditionException{
		if(!canHaveAsCondition(conditionOne)){
			throw new IllegalConditionException();
		}
		if(!canHaveAsCondition(conditionTwo)){
			throw new IllegalConditionException();
		}
		
		this.conditionOne = conditionOne;
		this.conditionTwo = conditionTwo;
	}
	
	/**
	 * The first condition of this binary composed condition.
	 */
	@Basic
	protected Condition getFirstCondition(){
		return this.conditionOne;
	}
	
	/**
	 * The first condition of this binary composed condition.
	 */
	@Basic
	protected Condition getSecondCondition(){
		return this.conditionTwo;
	}
}
